package org.example.smartbuy.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.example.smartbuy.entity.Orderdetails;
import org.example.smartbuy.mapper.OrderdetailsMapper;
import org.example.smartbuy.service.IOrderdetailsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Smarty Buy
 * @since 2024-11-18
 */
@Service
public class OrderdetailsServiceImpl extends ServiceImpl<OrderdetailsMapper, Orderdetails> implements IOrderdetailsService {
    @Autowired
    private OrderdetailsMapper orderDetailsMapper;

    @Override
    public List<Orderdetails> listById(int id) {
        QueryWrapper<Orderdetails> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id", id);
        return orderDetailsMapper.selectList(queryWrapper);
    }


    //创建订单的时候调用
    @Override
    public Orderdetails add(Orderdetails orderDetails) {
        orderDetailsMapper.insert(orderDetails);
        return orderDetails;
    }
}
